/** 
 * 上传图片上，将本地图片显示到浏览器上 
 */ 
/* function preImg(sourceId, targetId) { 
     var url = getFileUrl(sourceId); 
     var imgPre = document.getElementById(targetId); 
     imgPre.src = url; 
     console.log(url);
 }*/ 
 /** 
  * 获取图片url
  */ 
/*function getFileUrl(sourceId) { 
    var url; 
    if (navigator.userAgent.indexOf("MSIE")>=1) { // IE >6
        url = document.getElementById(sourceId).value; 
    } else if(navigator.userAgent.indexOf("Firefox")>0) { // Firefox 
        url = window.URL.createObjectURL(document.getElementById(sourceId).files.item(0)); 
    } else if(navigator.userAgent.indexOf("Chrome")>0) { // Chrome 
        url = window.URL.createObjectURL(document.getElementById(sourceId).files.item(0)); 
    } 
    return url; 
}*/

/** 
 * 读取身份信息
 */
function submitRegister(){
	var congtent = fingermark.ReadContent();
	if(congtent == "1"){
		$.messager.alert('提示信息','身份信息读取成功!');
	}else{
		$.messager.alert('提示信息','未放卡或卡片信息不正确!');
	}
	$("#OWNERTYPE").val("个人");
	$("#OWNERNAME").val(fingermark.GetName());
	$("#SFZHM").val(fingermark.GetSFZMHM());
}
/** 
 * 开启高拍仪拍照并回显
 */
function paizhao(x) {
	var url = cxt +'/commonUtil/gpy';
	var content = '<iframe id="iframeId" src='+url+' width="100%" height="99%" frameborder="0" scrolling="no"></iframe>';
	var boarddiv = '<div id="win" title="title"></div>';

	$(document.body).append(boarddiv);
	var win = $('#win').dialog({
		content: content,
		width: '820px',
		height: '530px',
		modal: 'shadow',
		title: '照片信息采集',
		onClose: function () {
			$(this).dialog('destroy');//后面可以关闭后的事件
		},
		buttons:[{
					text:"确定",
					handler:function(){
						//获取子页面元素 
						var base64str = document.getElementById('iframeId').contentWindow.document.getElementById("img1").src; 
						$("#xmTanImg"+x).attr('src',base64str);
						$("#picStr"+x).val(base64str);
						//window.top.reload_dataList.call();
						document.getElementById('iframeId').contentWindow.document.getElementById('Button2').click();
						$("#win").dialog("close");
					}
				},{
					text:"取消",
					handler:function(){
						document.getElementById('iframeId').contentWindow.document.getElementById('Button2').click();
						$("#win").dialog("close");
					}
		}]
	});
	win.dialog('open');
}
/** 
 * 业务图片回显
 */
function showPicture(businessids){
	getPicture(businessids,'PICTURE1','xmTanImg1','picStr1');
	getPicture(businessids,'PICTURE2','xmTanImg2','picStr2');
	getPicture(businessids,'PICTURE3','xmTanImg3','picStr3');
	getPicture(businessids,'PICTURE4','xmTanImg4','picStr4');
};
/** 
 * 获取数据库图片
 */
function getPicture(businessids,picturename,xmTanImg,picstr) {
	$.ajax({
		cache: true,
		type: "POST",
		url: cxt+"/commonUtil/getPicture",
		data: {
			businessids: businessids,
			picturename: picturename
		},
		dataType: 'json',
		async: false,
		success: function(result) {
			if(result != null) {
				$("#"+xmTanImg).attr('src',result.picstr);
				$("#"+picstr).val(result.picstr);
			}
		}
	});
}

/** 
 * 照片预览
 */
function yulan(x) {
	var base64str = $("#picStr"+x).val();
	if(base64str.length > 0){
		var image = '<img id="" width="812px" height="482px" src='+base64str+'/></br>';
		var boarddiv = '<div id="win" title="title"></div>';
		
		$(document.body).append(boarddiv);
		var win = $('#win').dialog({
			content: image,
			width: '820px',
			height: '530px',
			modal: 'shadow',
			title: '照片预览',
			onClose: function () {
				$(this).dialog('destroy');//后面可以关闭后的事件
			}
		});
		win.dialog('open');
	}
}
